<template>
  <div>
    <el-select v-model="valuesetion" multiple placeholder="请选择" style="width: 100%;" @change="sectionChange">
      <el-option
              v-for="item in sectionList"
              :key="item.id"
              :label="item.section_name"
              :value="item.id">
      </el-option>
    </el-select>
  </div>
</template>
<script>
  import api from '@/utils/api.js'
  import {pagination} from '@/utils/util.js'

  export default {
    name: 'sectioninput',
    props: ['sectionId', 'value1'],
    data () {
      return {
        sectionList: [],
        valuesetion: [],
        page: {
          pageindex: pagination.pageIndex,
          pagesize: pagination.pageSize,
          total: pagination.total
        }
      }
    },
    watch: {
      value1(){
        this.valuesetion = JSON.parse(JSON.stringify(this.value1))
      }
    },
    created () {
      console.log('this.value1:', this.value1)
      this.valuesetion = JSON.parse(JSON.stringify(this.value1))
      this.initFn()
    },
    methods: {
      initFn () {
        this.$fetch(api.user_sectionindex, {p: this.page.pageindex}).then((response) => {
          if (response.code === 0) {
            this.sectionList = response.list.data
          } else {
          }
        }).catch((err) => {
          console.log(err)
        })
      },
      sectionChange () {
        this.$emit('changeSectionMore', this.valuesetion)
      }
    },
    mounted () {
    }
  }
</script>
